﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Diagnostics;
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;


namespace Pasteur
{
    public class PasteurBagItems
    {
        private static LocalPlayer Me { get { return StyxWoW.Me; } }

        public bool FlaskBuff()
        {
            if (Me.HasAura("Flask of the Warm Sun")) { return true; }
            if (Me.HasAura("Flask of Winter's Bite")) { return true; }
            if (Me.HasAura("Flask of the Earth")) { return true; }
            if (Me.HasAura("Flask of Spring Blossoms")) { return true; }
            if (Me.HasAura("Flask of Falling Leaves")) { return true; }
            if (Me.HasAura("Flask of the Winds")) { return true; }
            if (Me.HasAura("Flask of Titanic Strenght")) { return true; }
            if (Me.HasAura("Flask of the Draconic Mind")) { return true; }
            if (Me.HasAura("Flask of Flowing Water")) { return true; }
            if (Me.HasAura("Flask of Steelskin")) { return true; }
            if (Me.HasAura("Flask of Endless Rage")) { return true; }
            if (Me.HasAura("Flask of Pure Mojo")) { return true; }
            if (Me.HasAura("Flask of Stoneblood")) { return true; }
            if (Me.HasAura("Flask of the Frost Wyrm")) { return true; }
            if (Me.HasAura("Flask of Toughness")) { return true; }
            if (Me.HasAura("Flask of Binding Light")) { return true; }
            return false;
        }

        #region BagItems
        public bool AlchemistFlask()
        {
            if (PasteurSettings.myPrefs.AlchFlask)
            {

                if (!Me.HasAura("Enhanced Intellect") && !FlaskBuff() && !Me.Mounted)
                {
                    foreach (WoWItem item in Me.BagItems)
                    {
                        if (item != null)
                        {
                            if (item.Name == "Alchemist's Flask")
                            {
                                Lua.DoString("RunMacroText(\"/use " + item.Name + "\")");
                                Logging.Write(Colors.LightBlue, "Using Alchemist's Flask");
                                break;
                            }
                        }
                    }
                }
            }
             
            return false;
        }
        public bool HealthStone()
        {
            if (Me.Combat && Me.HealthPercent <= PasteurSettings.myPrefs.healthstone)
            {
                WoWItem hstone = Me.BagItems.FirstOrDefault(h => h.Entry == 5512);
                if (hstone != null && hstone.CooldownTimeLeft.TotalMilliseconds <= 0)
                {
                    hstone.Use();
                    Logging.Write(Colors.BlanchedAlmond, "Using Healthstone");
                }
            }
            return false;
        }
        public bool LifeSpirit()
        {
            if (Me.Combat && Me.HealthPercent <= PasteurSettings.myPrefs.lifespirit)
            {
                WoWItem lspirit = Me.BagItems.FirstOrDefault(h => h.Entry == 89640);
                if (lspirit != null && lspirit.CooldownTimeLeft.TotalMilliseconds <= 0)
                {
                    lspirit.Use();
                    Logging.Write(Colors.BlanchedAlmond, "Using Life Spirit");
                }
            }
            return false;
        }
        public bool WaterSpirit()
        {
            if (Me.Combat && Me.ManaPercent <= PasteurSettings.myPrefs.waterspirit)
            {
                WoWItem wspirit = Me.BagItems.FirstOrDefault(h => h.Entry == 89641);
                if (wspirit != null && wspirit.CooldownTimeLeft.TotalMilliseconds <= 0)
                {
                    wspirit.Use();
                    Logging.Write(Colors.BlanchedAlmond, "Using Water Spirit");
                }
            }
            return false;
        }
        #endregion BagItems
    }
}
